package offer;

public class offer_0028 {
    public boolean isSymmetric(TreeNode root) {
        boolean[] flag=new boolean[1];
        flag[0]=true;
        if(root==null ) return true;
        is(root.left,root.right,flag);
        return flag[0];
    }
    public void is(TreeNode node1,TreeNode node2,boolean[] flag){
        if(node1==null&&node2==null) return;
        if(node1==null&&node2!=null) {
            flag[0]=false;
            return;
        }
        if(node2==null&&node1!=null) {
            flag[0]=false;
            return;
        }
        if(node1.val!=node2.val){
            flag[0]=false;
            return;
        }
        is(node1.left,node2.right,flag);
        is(node1.right,node2.left,flag);
    }
}
